package com.qf.service.impl;

import com.qf.mapper.UserTableMapper;
import com.qf.pojo.UserTable;
import com.qf.service.USerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements USerService {

    @Autowired
    private UserTableMapper mapper;

    @Override
    public List<UserTable> findAll() {
        return mapper.selectByExample(null);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        //第一种方式
        /*for (Integer id : ids) {
            mapper.deleteByPrimaryKey(id);
        }*/

        //第二种方式
        mapper.deleteAll(ids);
    }

    @Override
    public List<UserTable> excel(Integer[] ids) {
        return mapper.excel(ids);
    }

    @Override
    public void updateUser(UserTable userTable) {
        mapper.updateByPrimaryKeySelective(userTable);
    }

    @Override
    public void deleteById(Integer id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void addUser(UserTable userTable) {
        mapper.insertSelective(userTable);
    }
}
